package com.readbook.util;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

/**
 * 配置文件
 *
 * @author L.cm
 * email: 596392912@qq.com
 * site:  http://www.dreamlu.net
 */
@SuppressWarnings("all")
public class ConfKit {
    private static Properties props = new Properties();
    private String properurl;

    public ConfKit(String properurl) {
        this.properurl = properurl;
        try {
            //play框架下要用这种方式加载
            props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(properurl));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
	/*static {
		try {
			//play框架下要用这种方式加载
			props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("/zfb.properties"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}*/

    public String get(String key) {
        return props.getProperty(key);
    }

    public static void setProps(Properties p) {
        props = p;
    }
}
